#ifndef THREADPOOL_H
#define THREADPOOL_H

#include <pthread.h>

// 任务结构
typedef struct {
    void (*function)(void *);
    void *argument;
} ThreadPoolTask;

// 线程池结构
typedef struct {
    pthread_t *threads;
    ThreadPoolTask *taskQueue;
    int threadCount;
    int queueCapacity;
    int queueSize;
    int queueFront;
    int queueRear;
    pthread_mutex_t mutex;
    pthread_cond_t condition;
    int shutdown;
} ThreadPool;

// 线程池相关函数声明
ThreadPool *threadPoolCreate(int threadCount, int queueCapacity);
int threadPoolAddTask(ThreadPool *pool, void (*function)(void *), void *argument);
int threadPoolGetTaskCount(ThreadPool *pool);
void threadPoolDestroy(ThreadPool *pool);

#endif // THREADPOOL_H